//
//  MyOrderCell.m
//  OrderSeat
//
//  Created by haiming on 13-10-9.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "MyOrderCell.h"



#define  OTIME   1001
#define  DTIME   1002
#define  RNAME   1003
#define  ADDTIME 1004
#define  OSTATUS 1005
@implementation MyOrderCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        // Initialization code
    }
    return self;
}

- (void)setContent:(NSDictionary *)dic
{
    UILabel *orderTimeLabel = (UILabel *)[self.contentView viewWithTag:OTIME];
    UILabel *dinnerTimeLabel = (UILabel *)[self.contentView viewWithTag:DTIME];
    UILabel *rNameLabel = (UILabel *)[self.contentView viewWithTag:RNAME];
    UILabel *addTimeLabel = (UILabel *)[self.contentView viewWithTag:ADDTIME];
    UILabel *orderStatusLabel = (UILabel *)[self.contentView viewWithTag:OSTATUS];

    NSString *state = [dic objectForKey:@"zt"];
    NSString *dname = [dic objectForKey:@"dname"];
    NSString *zaowan = [dic objectForKey:@"zaowan"];
    NSString *order_time = [dic objectForKey:@"order_time"];
    NSString *add_time = [dic objectForKey:@"add_time"];
    
    orderTimeLabel.text = order_time;
    dinnerTimeLabel.text = zaowan;
    rNameLabel.text = dname;
    addTimeLabel.text = add_time;
    
    orderStatusLabel.text = state;
    orderStatusLabel.textColor = [self colorWithState:state];
    [orderStatusLabel autoWidthForSingleLine];
    
    
    [self reLayoutSubviews];
}

- (void)reLayoutSubviews
{
    [_view drawBorder];
}

- (UIColor *)colorWithState:(NSString *)state
{
    NSString *colorStr = @"#F0F0F0";
    if ([state isEqualToString:@"未确认"]) {
        colorStr = @"#D9D9D9";
    }
    
    if ([state isEqualToString:@"已确认"] || [state isEqualToString:@"已到店就餐"]) {
        colorStr = @"#FFA54F";
    }
    
    UIColor *color = [UIColor colorWithHexString:colorStr];
    
    return color;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
